package cn.lhl.service.cargo;

import cn.lhl.dao.cargo.ExtCproductDao;
import cn.lhl.domain.cargo.ExtCproduct;
import cn.lhl.domain.cargo.ExtCproductExample;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class ExtCproductServiceImpl implements ExtCproductService {
    @Autowired
    private ExtCproductDao extCproductDao;

    //分页查询所有
    public PageInfo findAll(ExtCproductExample extCproductExample, int page, int size) {
        PageHelper.startPage(page,size);
        List<ExtCproduct> extCproductList = extCproductDao.selectByExample(extCproductExample);
        return new PageInfo(extCproductList);
    }

    //根据id查询
    public ExtCproduct findById(String id) {
        ExtCproduct extCproduct = extCproductDao.selectByPrimaryKey(id);
        return extCproduct;
    }

    public void save(ExtCproduct extCproduct) {
        extCproductDao.insertSelective(extCproduct);
        //新增附件
    }

    public void update(ExtCproduct extCproduct) {
        extCproductDao.updateByPrimaryKeySelective(extCproduct);
    }

    public void delete(String id) {
        extCproductDao.deleteByPrimaryKey(id);
    }
}
